package calao.test.storage;

import calao.storage.Field;
import calao.storage.Schema;
import calao.storage.Table;
import calao.storage.Index;
import calao.storage.Record;

class Contact
extends Record
{

	static final Table TABLE = new Table("Contact"); 
	
	static final Field<Integer> ID = 
		TABLE.createField("id", Field.INTEGER);
	
	static final Field<String> EMAIL = 
		TABLE.createField("email", Field.STRING);
	
	static final Field<String> PHONE = 
		TABLE.createField("phone", Field.STRING);
	
	static final Field<Integer> GROUP = 
		TABLE.createField("group", Field.INTEGER, true);
	
	static final Index INDEX = TABLE.createPrimaryKeyIndex(ID);
	
	static final Index EMAIL_INDEX = TABLE.createIndex(EMAIL);
	
	static final Index GROUP_INDEX = TABLE.createIndex(GROUP);
	
	static {
		Schema schema = new Schema();
		schema.add(TABLE);
		schema.register();
	}
		
	Contact(int id, String email, String phone, Integer... groups)
	{
		super(TABLE);
		set(Contact.ID, id);
		set(Contact.EMAIL, email);
		set(Contact.PHONE, phone);
		set(Contact.GROUP, groups);
	}
	
}
